package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @Author by 孙有泽
 * @Date 2025/2/28 11:38
 * @Description
 */
@Mapper
public interface SetmealMapper {
    /*
     * @author 孙有泽
     * @date 2025/2/28 11:42
     * @description 根据菜品分类查询套餐数量
     */
    Integer selectCountByCategoryId(@Param("categoryId") Long categoryId);
    /*
     * @author 孙有泽
     * @date 2025/3/3 21:49
     * @description 套餐新增
     */
    @AutoFill(OperationType.INSERT)
    void save(Setmeal setmeal);

    /*
     * @author 孙有泽
     * @date 2025/3/3 22:21
     * @description 套餐列表
     */
    Page<SetmealVO> list(SetmealPageQueryDTO setmealPageQueryDTO);

    /*
     * @author 孙有泽
     * @date 2025/3/3 22:24
     * @description 套餐的停售和启用
     */
    void update(Setmeal setmeal);
    /*
     * @author 孙有泽
     * @date 2025/3/4 9:30
     * @description 根据id查询
     */
    Setmeal getById(Long id);

    void deleteById(Long id);

    /**
     * 动态条件查询套餐
     * @param setmeal
     * @return
     */
    List<Setmeal> listSetMeal(Setmeal setmeal);

    /**
     * 根据套餐id查询菜品选项
     * @param setmealId
     * @return
     */
    @Select("select sd.name, sd.copies, d.image, d.description " +
            "from setmeal_dish sd left join dish d on sd.dish_id = d.id " +
            "where sd.setmeal_id = #{setmealId}")
    List<DishItemVO> getDishItemBySetmealId(Long setmealId);

}
